package com.gs.thunder_manage.service.impl;

import com.gs.thunder_manage.dao.RoleDao;
import com.gs.thunder_manage.entity.Resource;
import com.gs.thunder_manage.entity.Role;
import com.gs.thunder_manage.service.RoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService{
    private Logger logger = LoggerFactory.getLogger(RoleServiceImpl.class);

    @Autowired
    private RoleDao roleDao;

    //添加角色
    public void addRole(Role role){
        roleDao.addRole(role);
    }
    //新增角色资源
    public void addRoleResource(int roleId, int resId){
            roleDao.addRoleResource(roleId, resId);
    }
    //更新角色
    public void updateRole(Role role){
        roleDao.updateRole(role);
    }
    //通过id查询角色信息
    public Role queryRoleById(int id){
        return roleDao.queryRoleById(id);
    }

    public List<Role> queryAllRole() {
        return roleDao.queryAllRole();
    }

    public List<Resource> queryResourceByRoleId(int roleId) {
        return roleDao.queryResourceByRoleId(roleId);
    }

    //删除角色
    public void deleteRole(int id){
        roleDao.deleteRole(id);
    }
    //删除角色资源记录
    public void deleteRoleResource(int roleId, int resId) {
        roleDao.deleteRoleResource(roleId, resId);
    }

}
